package com.zzt.zt_hilt.container

import com.zzt.zt_hilt.entity.UserLocalDataSource
import com.zzt.zt_hilt.entity.UserRemoteDataSource
import com.zzt.zt_hilt.entity.UserRepository
import com.zzt.zt_hilt.factory.LoginViewModelFactory
import com.zzt.zt_hilt.service.LoginService
import retrofit2.Retrofit

/**
 * @author: zeting
 * @date: 2022/8/30
 *
 */
// Container of objects shared across the whole app
class AppContainer {

    // Since you want to expose userRepository out of the container, you need to satisfy
    // its dependencies as you did before
    private val retrofit = Retrofit.Builder()
        .baseUrl("https://example.com")
        .build()
        .create(LoginService::class.java)

    private val remoteDataSource = UserRemoteDataSource(retrofit)
    private val localDataSource = UserLocalDataSource()

    // userRepository is not private; it'll be exposed
    val userRepository = UserRepository(localDataSource, remoteDataSource)

    val loginViewModelFactory = LoginViewModelFactory(userRepository)



    /**********************测试数据**********************/

    /**********************测试数据**********************/


    val userRepository3 = UserRepository(localDataSource, remoteDataSource)

    // LoginContainer will be null when the user is NOT in the login flow
    var loginContainer: LoginContainer? = null

}